home *** CD-ROM | disk | FTP | other *** search
-
- class List {
- public:
- List() { head = 0; }
- ~List() {}
- Truth isempty() { return head == 0; }
- T get() { return head->value(); }
- void add(T x) { /* as before */ }
- T del() { /* as before */ }
- private:
- Node *head;
-
- friend It; // It is still a friend of List
- // tail returns the tail of the List. cdr in LISP.
- List tail()
- {
- List r;
- if( !isempty() )
- r.head = head->next();
- return r;
- }
- };
-
-